package cn.edu.nhic.nhcarsb.controller.admin;

import cn.edu.nhic.nhcarsb.controller.BaseController;
import cn.edu.nhic.nhcarsb.entity.R;
import cn.edu.nhic.nhcarsb.utils.FileUploadUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/admin/upload")
public class UploadController extends BaseController {
    @PostMapping
    public R upload(MultipartFile file, HttpServletRequest request){
        FileUploadUtil uploadUtil = new FileUploadUtil();
        String fname = uploadUtil.upload(file,request.getServletContext());
        return R.success(fname);
    }
}
